Skip to content

rollup-plugin-ts not compatible with TypeScript 4.7-4.9 #196

@matthew-dean

Description

@matthew-dean

Sorry, don't have time to leave a proper bug report, but just wanted to flag this sooner rather than later.

After upgrading to TypeScript 4.9.3, this plugin fails with an error message like:

TypeError: path.charCodeAt is not a function
    at getEncodedRootLength (.../node_modules/.pnpm/typescript@4.9.3/node_modules/typescript/lib/typescript.js:7683:24)

If you log the path, it (or Rollup? it's not clear) is returning { pos: 22, end: 27, fileName: 'react' } when resolving React for a .d.ts file like:

/// <reference types="react" />
declare const createReducerContext: <R extends import("react").Reducer<any, any>>(reducer: R, defaultInitialState: import("react").ReducerState<R>) => readonly [() => [import("react").ReducerState<R>, import("react").Dispatch<import("react").ReducerAction<R>>], ({ children, initialState, }: {
    children?: React.ReactNode;
    initialState?: import("react").ReducerState<R> | undefined;
}) => import("react").FunctionComponentElement<import("react").ProviderProps<[import("react").ReducerState<R>, import("react").Dispatch<import("react").ReducerAction<R>>] | undefined>>, import("react").Context<[import("react").ReducerState<R>, import("react").Dispatch<import("react").ReducerAction<R>>] | undefined>];
export default createReducerContext;

The resolved moduleName is not a string, so TypeScript crashes.

I installed versions of TypeScript 4.6.4-4.9.3 and from 4.7 on, this fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions