Skip to content

--moduleResolution minimal #50153

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

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add non-relative tests
  • Loading branch information
andrewbranch committed Jul 29, 2022
commit 2421cf58ab4527288c26668e0e1e39e19a598dfe
18 changes: 18 additions & 0 deletions tests/baselines/reference/minimal_nonRelative.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/main.ts(1,16): error TS2307: Cannot find module 'foo' or its corresponding type declarations.
/main.ts(2,16): error TS2307: Cannot find module 'bar' or its corresponding type declarations.


==== /node_modules/@types/foo/index.d.ts (0 errors) ====
export {};

==== /node_modules/bar/index.d.ts (0 errors) ====
export {};

==== /main.ts (2 errors) ====
import {} from "foo";
~~~~~
!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations.
import {} from "bar";
~~~~~
!!! error TS2307: Cannot find module 'bar' or its corresponding type declarations.

14 changes: 14 additions & 0 deletions tests/baselines/reference/minimal_nonRelative.trace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
"======== Resolving module 'foo' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"======== Module name 'foo' was not resolved. ========",
"======== Resolving module 'bar' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"======== Module name 'bar' was not resolved. ========",
"======== Resolving type reference directive 'foo', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========"
]
38 changes: 38 additions & 0 deletions tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/main.ts(4,16): error TS2307: Cannot find module 'hello' or its corresponding type declarations.


==== /tsconfig.json (0 errors) ====
{
"compilerOptions": {
"moduleResolution": "minimal",
"noEmit": true,
"baseUrl": ".",
"paths": {
"*": [
"*",
"./vendor/*",
"./vendor/*/index.d.ts",
"./apps/*"
]
}
}
}

==== /vendor/foo/index.d.ts (0 errors) ====
export {};

==== /apps/hello.ts (0 errors) ====
export {};

==== /foo.ts (0 errors) ====
export {};

==== /main.ts (1 errors) ====
import {} from "foo";
import {} from "foo/index.js";
import {} from "hello.ts";
import {} from "hello";
~~~~~~~
!!! error TS2307: Cannot find module 'hello' or its corresponding type declarations.
import {} from "foo.js";

73 changes: 73 additions & 0 deletions tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[
"======== Resolving module 'foo' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo'.",
"'paths' option is specified, looking for a pattern to match module name 'foo'.",
"Module name 'foo', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'foo'.",
"Trying substitution './vendor/*', candidate module location: './vendor/foo'.",
"Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/foo/index.d.ts'.",
"File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'foo' was successfully resolved to '/vendor/foo/index.d.ts'. ========",
"======== Resolving module 'foo/index.js' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/index.js'.",
"'paths' option is specified, looking for a pattern to match module name 'foo/index.js'.",
"Module name 'foo/index.js', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'foo/index.js'.",
"File name '/foo/index.js' has a '.js' extension - stripping it.",
"Trying substitution './vendor/*', candidate module location: './vendor/foo/index.js'.",
"File name '/vendor/foo/index.js' has a '.js' extension - stripping it.",
"File '/vendor/foo/index.ts' does not exist.",
"File '/vendor/foo/index.tsx' does not exist.",
"File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'foo/index.js' was successfully resolved to '/vendor/foo/index.d.ts'. ========",
"======== Resolving module 'hello.ts' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello.ts'.",
"'paths' option is specified, looking for a pattern to match module name 'hello.ts'.",
"Module name 'hello.ts', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'hello.ts'.",
"File name '/hello.ts' has a '.ts' extension - stripping it.",
"File '/hello.ts' does not exist.",
"Trying substitution './vendor/*', candidate module location: './vendor/hello.ts'.",
"File name '/vendor/hello.ts' has a '.ts' extension - stripping it.",
"File '/vendor/hello.ts' does not exist.",
"Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello.ts/index.d.ts'.",
"File '/vendor/hello.ts/index.d.ts' does not exist.",
"File name '/vendor/hello.ts/index.d.ts' has a '.d.ts' extension - stripping it.",
"Trying substitution './apps/*', candidate module location: './apps/hello.ts'.",
"File name '/apps/hello.ts' has a '.ts' extension - stripping it.",
"File '/apps/hello.ts' exist - use it as a name resolution result.",
"======== Module name 'hello.ts' was successfully resolved to '/apps/hello.ts'. ========",
"======== Resolving module 'hello' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.",
"'paths' option is specified, looking for a pattern to match module name 'hello'.",
"Module name 'hello', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'hello'.",
"Trying substitution './vendor/*', candidate module location: './vendor/hello'.",
"Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.",
"File '/vendor/hello/index.d.ts' does not exist.",
"File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.",
"Trying substitution './apps/*', candidate module location: './apps/hello'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.",
"'paths' option is specified, looking for a pattern to match module name 'hello'.",
"Module name 'hello', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'hello'.",
"Trying substitution './vendor/*', candidate module location: './vendor/hello'.",
"Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.",
"File '/vendor/hello/index.d.ts' does not exist.",
"File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.",
"Trying substitution './apps/*', candidate module location: './apps/hello'.",
"======== Module name 'hello' was not resolved. ========",
"======== Resolving module 'foo.js' from '/main.ts'. ========",
"Explicitly specified module resolution kind: 'Minimal'.",
"'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo.js'.",
"'paths' option is specified, looking for a pattern to match module name 'foo.js'.",
"Module name 'foo.js', matched pattern '*'.",
"Trying substitution '*', candidate module location: 'foo.js'.",
"File name '/foo.js' has a '.js' extension - stripping it.",
"File '/foo.ts' exist - use it as a name resolution result.",
"======== Module name 'foo.js' was successfully resolved to '/foo.ts'. ========"
]
14 changes: 14 additions & 0 deletions tests/cases/conformance/moduleResolution/minimal_nonRelative.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @moduleResolution: minimal
// @noEmit: true
// @traceResolution: true
// @noTypesAndSymbols: true

// @Filename: /node_modules/@types/foo/index.d.ts
export {};

// @Filename: /node_modules/bar/index.d.ts
export {};

// @Filename: /main.ts
import {} from "foo";
import {} from "bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// @traceResolution: true
// @noTypesAndSymbols: true

// @Filename: /tsconfig.json
{
"compilerOptions": {
"moduleResolution": "minimal",
"noEmit": true,
"baseUrl": ".",
"paths": {
"*": [
"*",
"./vendor/*",
"./vendor/*/index.d.ts",
"./apps/*"
]
}
}
}

// @Filename: /vendor/foo/index.d.ts
export {};

// @Filename: /apps/hello.ts
export {};

// @Filename: /foo.ts
export {};

// @Filename: /main.ts
import {} from "foo";
import {} from "foo/index.js";
import {} from "hello.ts";
import {} from "hello";
import {} from "foo.js";
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy