Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13105 from Microsoft/Fix12921
Check for `.js` targets for `package.json`::`main`
- Loading branch information
Showing
10 changed files
with
168 additions
and
30 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
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/untypedModuleImport_MainInPackageJson.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,22 @@ | ||
//// [tests/cases/conformance/moduleResolution/untypedModuleImport_MainInPackageJson.ts] //// | ||
|
||
//// [foo.js] | ||
// This tests that importing from a JS file globally works in an untyped way. | ||
// (Assuming we don't have `--noImplicitAny` or `--allowJs`.) | ||
|
||
This file is not processed. | ||
|
||
//// [package.json] | ||
{ | ||
"main": "lib/foo" | ||
} | ||
|
||
//// [a.ts] | ||
import * as foo from "foo"; | ||
foo.bar(); | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
var foo = require("foo"); | ||
foo.bar(); |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/untypedModuleImport_MainInPackageJson.symbols
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,7 @@ | ||
=== /a.ts === | ||
import * as foo from "foo"; | ||
>foo : Symbol(foo, Decl(a.ts, 0, 6)) | ||
|
||
foo.bar(); | ||
>foo : Symbol(foo, Decl(a.ts, 0, 6)) | ||
|
10 changes: 10 additions & 0 deletions
10
tests/baselines/reference/untypedModuleImport_MainInPackageJson.types
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,10 @@ | ||
=== /a.ts === | ||
import * as foo from "foo"; | ||
>foo : any | ||
|
||
foo.bar(); | ||
>foo.bar() : any | ||
>foo.bar : any | ||
>foo : any | ||
>bar : any | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/untypedModuleImport_noImplicitAny2.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,18 @@ | ||
/a.ts(1,22): error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/lib/foo.js' implicitly has an 'any' type. | ||
|
||
|
||
==== /a.ts (1 errors) ==== | ||
import * as foo from "foo"; | ||
~~~~~ | ||
!!! error TS7016: Could not find a declaration file for module 'foo'. '/node_modules/foo/lib/foo.js' implicitly has an 'any' type. | ||
|
||
==== /node_modules/foo/lib/foo.js (0 errors) ==== | ||
// This tests that `--noImplicitAny` disables untyped modules. | ||
|
||
This file is not processed. | ||
|
||
==== /node_modules/foo/package.json (0 errors) ==== | ||
{ | ||
"main": "lib/foo" | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/untypedModuleImport_noImplicitAny2.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,18 @@ | ||
//// [tests/cases/conformance/moduleResolution/untypedModuleImport_noImplicitAny2.ts] //// | ||
|
||
//// [foo.js] | ||
// This tests that `--noImplicitAny` disables untyped modules. | ||
|
||
This file is not processed. | ||
|
||
//// [package.json] | ||
{ | ||
"main": "lib/foo" | ||
} | ||
|
||
//// [a.ts] | ||
import * as foo from "foo"; | ||
|
||
|
||
//// [a.js] | ||
"use strict"; |
16 changes: 16 additions & 0 deletions
16
tests/cases/conformance/moduleResolution/untypedModuleImport_MainInPackageJson.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,16 @@ | ||
// @noImplicitReferences: true | ||
// @currentDirectory: / | ||
// This tests that importing from a JS file globally works in an untyped way. | ||
// (Assuming we don't have `--noImplicitAny` or `--allowJs`.) | ||
|
||
// @filename: /node_modules/foo/lib/foo.js | ||
This file is not processed. | ||
|
||
// @filename: /node_modules/foo/package.json | ||
{ | ||
"main": "lib/foo" | ||
} | ||
|
||
// @filename: /a.ts | ||
import * as foo from "foo"; | ||
foo.bar(); |
15 changes: 15 additions & 0 deletions
15
tests/cases/conformance/moduleResolution/untypedModuleImport_noImplicitAny2.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,15 @@ | ||
// @noImplicitReferences: true | ||
// @currentDirectory: / | ||
// @noImplicitAny: true | ||
// This tests that `--noImplicitAny` disables untyped modules. | ||
|
||
// @filename: /node_modules/foo/lib/foo.js | ||
This file is not processed. | ||
|
||
// @filename: /node_modules/foo/package.json | ||
{ | ||
"main": "lib/foo" | ||
} | ||
|
||
// @filename: /a.ts | ||
import * as foo from "foo"; |