Skip to content

Store and check deferred nodes by containing file #27378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ namespace ts {
let deferredGlobalImportMetaType: ObjectType;
let deferredGlobalExtractSymbol: Symbol;

let deferredNodes: Map<Node> | undefined;
const allPotentiallyUnusedIdentifiers = createMap<PotentiallyUnusedIdentifier[]>(); // key is file name

let flowLoopStart = 0;
Expand Down Expand Up @@ -21223,6 +21222,7 @@ namespace ts {

function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, checkMode?: CheckMode): Type {
Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node));
checkNodeDeferred(node);

// The identityMapper object is used to indicate that function expressions are wildcards
if (checkMode === CheckMode.SkipContextSensitive && isContextSensitive(node)) {
Expand Down Expand Up @@ -21280,7 +21280,6 @@ namespace ts {
}
}
checkSignatureDeclaration(node);
checkNodeDeferred(node);
}
}

Expand Down Expand Up @@ -27353,14 +27352,21 @@ namespace ts {
// determining the type of foo would cause foo to be given type any because of the recursive reference.
// Delaying the type check of the body ensures foo has been assigned a type.
function checkNodeDeferred(node: Node) {
if (deferredNodes) {
const enclosingFile = getSourceFileOfNode(node);
const links = getNodeLinks(enclosingFile);
if (!(links.flags & NodeCheckFlags.TypeChecked)) {
links.deferredNodes = links.deferredNodes || createMap();
const id = "" + getNodeId(node);
deferredNodes.set(id, node);
links.deferredNodes.set(id, node);
}
}

function checkDeferredNodes() {
deferredNodes!.forEach(node => {
function checkDeferredNodes(context: SourceFile) {
const links = getNodeLinks(context);
if (!links.deferredNodes) {
return;
}
links.deferredNodes.forEach(node => {
switch (node.kind) {
case SyntaxKind.FunctionExpression:
case SyntaxKind.ArrowFunction:
Expand Down Expand Up @@ -27421,10 +27427,9 @@ namespace ts {
clear(potentialThisCollisions);
clear(potentialNewTargetCollisions);

deferredNodes = createMap<Node>();
forEach(node.statements, checkSourceElement);

checkDeferredNodes();
checkDeferredNodes(node);

if (isExternalOrCommonJsModule(node)) {
registerForUnusedIdentifiersCheck(node);
Expand All @@ -27438,8 +27443,6 @@ namespace ts {
});
}

deferredNodes = undefined;

if (isExternalOrCommonJsModule(node)) {
checkExternalModuleExports(node);
}
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3702,6 +3702,7 @@ namespace ts {
switchTypes?: Type[]; // Cached array of switch case expression types
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
deferredNodes?: Map<Node>; // Set of nodes whose checking has been deferred
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
}

Expand Down
Submodule TypeScript-Node-Starter updated 49 files
+2 −11 .env.example
+1 −5 .gitignore
+0 −1 .vscode/extensions.json
+15 −3 .vscode/launch.json
+2 −8 .vscode/settings.json
+76 −192 README.md
+5 −0 copyStaticAssets.js
+0 −5 copyStaticAssets.ts
+0 −18 jest.config.js
+1,346 −1,722 package-lock.json
+59 −52 package.json
+19 −22 src/app.ts
+5 −5 src/config/passport.ts
+3 −3 src/controllers/api.ts
+1 −1 src/controllers/contact.ts
+6 −7 src/controllers/user.ts
+6 −9 src/models/User.ts
+1 −1 src/public/css/lib/bootstrap/_button-groups.scss
+1 −1 src/public/css/lib/bootstrap/_forms.scss
+1 −1 src/public/css/lib/bootstrap/_input-groups.scss
+1 −1 src/public/css/lib/bootstrap/_panels.scss
+1 −1 src/public/css/lib/bootstrap/_scaffolding.scss
+2 −2 src/public/css/lib/bootstrap/_theme.scss
+1 −1 src/public/css/lib/bootstrap/_variables.scss
+2 −2 src/public/css/lib/bootstrap/bootstrap.scss
+3 −3 src/public/css/lib/bootstrap/mixins/_tab-focus.scss
+ src/public/fonts/glyphicons-halflings-regular.eot
+0 −288 src/public/fonts/glyphicons-halflings-regular.svg
+ src/public/fonts/glyphicons-halflings-regular.ttf
+ src/public/fonts/glyphicons-halflings-regular.woff
+ src/public/fonts/glyphicons-halflings-regular.woff2
+4 −4 src/public/js/lib/jquery-3.1.1.min.js
+4 −8 src/server.ts
+2 −0 src/types/lusca.d.ts
+48 −0 src/types/passport-local.d.ts
+0 −17 src/util/logger.ts
+0 −26 src/util/secrets.ts
+2 −2 test/api.test.ts
+2 −2 test/app.test.ts
+2 −20 test/contact.test.ts
+2 −2 test/home.test.ts
+2 −20 test/user.test.ts
+0 −1 tsconfig.json
+1 −1 views/account/profile.pug
+1 −1 views/api/facebook.pug
+1 −1 views/api/index.pug
+9 −8 views/layout.pug
+3 −2 views/partials/footer.pug
+2 −2 views/partials/header.pug
Submodule TypeScript-React-Native-Starter updated 64 files
+0 −0 .babelrc
+0 −0 .buckconfig
+4 −12 .gitignore
+0 −0 .watchmanconfig
+0 −54 ExampleProject/.flowconfig
+0 −1 ExampleProject/.gitattributes
+0 −3 ExampleProject/android/app/src/main/res/values/strings.xml
+0 −3 ExampleProject/android/settings.gradle
+0 −4 ExampleProject/app.json
+0 −83 ExampleProject/components/Hello.tsx
+0 −9 ExampleProject/components/__tests__/Hello.tsx
+0 −175 ExampleProject/components/__tests__/__snapshots__/Hello.tsx.snap
+0 −4 ExampleProject/index.js
+0 −6 ExampleProject/ios/ExampleProject/Images.xcassets/Contents.json
+0 −29 ExampleProject/package-lock.json
+0 −8 ExampleProject/rn-cli.config.js
+0 −5,722 ExampleProject/yarn.lock
+325 −300 README.md
+2 −2 android/app/BUCK
+1 −12 android/app/build.gradle
+0 −0 android/app/proguard-rules.pro
+8 −2 android/app/src/main/AndroidManifest.xml
+2 −2 android/app/src/main/java/com/myawesomeproject/MainActivity.java
+1 −6 android/app/src/main/java/com/myawesomeproject/MainApplication.java
+ android/app/src/main/res/mipmap-hdpi/ic_launcher.png
+ android/app/src/main/res/mipmap-mdpi/ic_launcher.png
+ android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
+ android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
+3 −0 android/app/src/main/res/values/strings.xml
+0 −0 android/app/src/main/res/values/styles.xml
+0 −0 android/build.gradle
+0 −0 android/gradle.properties
+ android/gradle/wrapper/gradle-wrapper.jar
+0 −0 android/gradle/wrapper/gradle-wrapper.properties
+0 −0 android/gradlew
+90 −90 android/gradlew.bat
+0 −0 android/keystores/BUCK
+0 −0 android/keystores/debug.keystore.properties
+3 −0 android/settings.gradle
+4 −0 app.json
+2 −0 index.android.js
+2 −0 index.ios.js
+0 −0 ios/MyAwesomeProject-tvOS/Info.plist
+0 −0 ios/MyAwesomeProject-tvOSTests/Info.plist
+89 −176 ios/MyAwesomeProject.xcodeproj/project.pbxproj
+18 −18 ios/MyAwesomeProject.xcodeproj/xcshareddata/xcschemes/MyAwesomeProject-tvOS.xcscheme
+18 −18 ios/MyAwesomeProject.xcodeproj/xcshareddata/xcschemes/MyAwesomeProject.xcscheme
+0 −0 ios/MyAwesomeProject/AppDelegate.h
+2 −2 ios/MyAwesomeProject/AppDelegate.m
+1 −1 ios/MyAwesomeProject/Base.lproj/LaunchScreen.xib
+0 −0 ios/MyAwesomeProject/Images.xcassets/AppIcon.appiconset/Contents.json
+1 −1 ios/MyAwesomeProject/Info.plist
+0 −0 ios/MyAwesomeProject/main.m
+0 −0 ios/MyAwesomeProjectTests/Info.plist
+2 −2 ios/MyAwesomeProjectTests/MyAwesomeProjectTests.m
+17 −16 package.json
+12 −0 src/__tests__/index.android.tsx
+4 −4 src/__tests__/index.ios.tsx
+64 −0 src/components/Hello.tsx
+10 −0 src/components/__tests__/Hello.tsx
+9 −15 src/index.android.tsx
+53 −0 src/index.ios.tsx
+12 −19 tsconfig.json
+4,419 −0 yarn.lock
2 changes: 1 addition & 1 deletion tests/cases/user/create-react-app/create-react-app
Submodule create-react-app updated 220 files
2 changes: 1 addition & 1 deletion tests/cases/user/prettier/prettier
Submodule prettier updated 1789 files
2 changes: 1 addition & 1 deletion tests/cases/user/puppeteer/puppeteer
2 changes: 1 addition & 1 deletion tests/cases/user/webpack/webpack
Submodule webpack updated 1431 files