Add support for Glob-Patterns in "noResolvePaths"#1475
Merged
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom Aug 24, 2023
Merged
Add support for Glob-Patterns in "noResolvePaths"#1475Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
Perryvw merged 2 commits intoTypeScriptToLua:masterfrom
Conversation
Contributor
Author
|
Could we maybe have a new release after this is merged? - We'd desperately need this for a project ^^ |
Perryvw
requested changes
Aug 24, 2023
Member
Perryvw
left a comment
There was a problem hiding this comment.
Looks good, but before merging this I would like to have some tests added here: https://github.com/TypeScriptToLua/TypeScriptToLua/blob/master/test/transpile/module-resolution.spec.ts#L444
The test can simply check if there are no diagnostics for non-existing noResolvePaths (with a glob pattern), and that existing files are still resolved.
Something along these lines:
test("can ignore everything with glob pattern", () => {
util.testModule`
import * as a from "a";
import * as bc from "b/c";
import * as d from "./d";
import * as ef from "./e/f";
import
`
.addExtraFile("a.d.ts", "export function foo1(): void;")
.addExtraFile("b/c.d.ts", "export function foo2(): void;")
.addExtraFile("d.d.ts", "export function foo3(): void;")
.addExtraFile("e/f.d.ts", "export function foo4(): void;")
.setOptions({ noResolvePaths: ["*"] })
.expectToHaveNoDiagnostics();
});
test("can ignore specific files with glob pattern", () => {
util.testModule`
import * as a from "ignoreme1";
import * as b from "ignoreme2";
import * as c from "actualfile";
export const result = c.foo();
`
.addExtraFile("a.d.ts", "export function foo1(): void;")
.addExtraFile("b.d.ts", "export function foo2(): void;")
.addExtraFile("actualfile.ts", "export function foo() { return 'foo'; }")
.setOptions({ noResolvePaths: ["ignoreme*"] })
.expectToHaveNoDiagnostics()
.expectToEqual({ result: "foo" });
});(I haven't tested these to you might have to tweak them a little)
Contributor
Author
|
Alright, will add them shortly |
Contributor
Author
|
I've now added 3 tests
|
Perryvw
approved these changes
Aug 24, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for glob patterns in
noResolvePathsusing picomatch.Also supplies
0as the duration for the CachedInputFileSystem as updated typing requires so.This change should not change any caching behavior as it explicitly causes the current behavior to be used (see here)
Fixes #1161.