Skip to content
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

Build failed due to typescript type declaration #8

Open
willin opened this issue Nov 10, 2021 · 1 comment
Open

Build failed due to typescript type declaration #8

willin opened this issue Nov 10, 2021 · 1 comment

Comments

@willin
Copy link

willin commented Nov 10, 2021

./i18n/index.ts:2:16
Type error: Cannot find module './zh.yml' or its corresponding type declarations.

  1 | import './index.d';
> 2 | import zh from './zh.yml';
    |                ^
  3 | import en from './en.yml';
  4 | 
  5 | export default {
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@crucialfelix
Copy link

This fixes it:

types.d.ts

declare module '*.yml' {
  const data: any
  export default data
}

tsconfig.json

// ...
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "./types.d.ts"],

This tells typescript that webpack has magically enabled importing of yaml yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants