-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when checking module exports for export=
Also make maxNodeModuleJsDepth default to 0 so that incorrect tsconfigs now let the compiler spend less time compiling JS that is found in node_modules (especially since most people will already have the d.ts and want ignore the JS anyway). jsconfig still defaults to 2.
- Loading branch information
Showing
11 changed files
with
123 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
tests/cases/compiler/errorForConflictingExportEqualsValue.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. | ||
|
||
|
||
==== tests/cases/compiler/errorForConflictingExportEqualsValue.ts (1 errors) ==== | ||
export var x; | ||
export = {}; | ||
~~~~~~~~~~~~ | ||
!!! error TS2309: An export assignment cannot be used in a module with other exported elements. | ||
|
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/errorForConflictingExportEqualsValue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//// [errorForConflictingExportEqualsValue.ts] | ||
export var x; | ||
export = {}; | ||
|
||
|
||
//// [errorForConflictingExportEqualsValue.js] | ||
"use strict"; | ||
module.exports = {}; |
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
c:/root/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. | ||
|
||
|
||
==== c:/root/index.ts (1 errors) ==== | ||
/// <reference path="c:/root/typings/index.d.ts" /> | ||
import * as foo from "shortid"; | ||
foo.x // found in index.d.ts | ||
foo.y // ignored from shortid/index.ts | ||
~ | ||
!!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. | ||
|
||
|
||
==== c:/root/node_modules/shortid/node_modules/z/index.js (0 errors) ==== | ||
// z will not be found because maxNodeModulesJsDepth: 0 | ||
module.exports = { z: 'no' }; | ||
|
||
==== c:/root/node_modules/shortid/index.js (0 errors) ==== | ||
var z = require('z'); | ||
var y = { y: 'foo' }; | ||
module.exports = y; | ||
|
||
==== c:/root/typings/index.d.ts (0 errors) ==== | ||
declare module "shortid" { | ||
export var x: number; | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[ | ||
"======== Resolving module 'shortid' from 'c:/root/index.ts'. ========", | ||
"Explicitly specified module resolution kind: 'NodeJs'.", | ||
"Loading module 'shortid' from 'node_modules' folder.", | ||
"File 'c:/root/node_modules/shortid.ts' does not exist.", | ||
"File 'c:/root/node_modules/shortid.tsx' does not exist.", | ||
"File 'c:/root/node_modules/shortid.d.ts' does not exist.", | ||
"File 'c:/root/node_modules/shortid.js' does not exist.", | ||
"File 'c:/root/node_modules/shortid.jsx' does not exist.", | ||
"File 'c:/root/node_modules/shortid/package.json' does not exist.", | ||
"File 'c:/root/node_modules/shortid/index.ts' does not exist.", | ||
"File 'c:/root/node_modules/shortid/index.tsx' does not exist.", | ||
"File 'c:/root/node_modules/shortid/index.d.ts' does not exist.", | ||
"File 'c:/root/node_modules/shortid/index.js' exist - use it as a name resolution result.", | ||
"File 'c:/root/node_modules/@types/shortid.ts' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid.tsx' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid.d.ts' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid.js' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid.jsx' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/package.json' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/index.ts' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/index.tsx' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/index.d.ts' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/index.js' does not exist.", | ||
"File 'c:/root/node_modules/@types/shortid/index.jsx' does not exist.", | ||
"Resolving real path for 'c:/root/node_modules/shortid/index.js', result 'c:/root/node_modules/shortid/index.js'", | ||
"======== Module name 'shortid' was successfully resolved to 'c:/root/node_modules/shortid/index.js'. ========" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export var x; | ||
export = {}; |
36 changes: 36 additions & 0 deletions
36
tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// @module: commonjs | ||
// @moduleResolution: node | ||
// @allowJs: true | ||
// @traceResolution: true | ||
// @noEmit: true | ||
|
||
// @filename: c:/root/tsconfig.json | ||
{ | ||
"compileOnSave": true, | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"outDir": "bin" | ||
}, | ||
"exclude": [ "node_modules" ] | ||
} | ||
// @filename: c:/root/node_modules/shortid/node_modules/z/index.js | ||
// z will not be found because maxNodeModulesJsDepth: 0 | ||
module.exports = { z: 'no' }; | ||
|
||
// @filename: c:/root/node_modules/shortid/index.js | ||
var z = require('z'); | ||
var y = { y: 'foo' }; | ||
module.exports = y; | ||
|
||
// @filename: c:/root/typings/index.d.ts | ||
declare module "shortid" { | ||
export var x: number; | ||
} | ||
|
||
// @filename: c:/root/index.ts | ||
/// <reference path="c:/root/typings/index.d.ts" /> | ||
import * as foo from "shortid"; | ||
foo.x // found in index.d.ts | ||
foo.y // ignored from shortid/index.ts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters