-
Couldn't load subscription status.
- Fork 265
Rename generated types file #826
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
base: 2.x
Are you sure you want to change the base?
Conversation
|
What is the actual underlying issue here? Do you know why this fixes the issues in that discussion thread? |
|
@bakerkretzmar |
|
Do you know why this is a problem or what's actually causing it? |
|
@bakerkretzmar Unfortunately no. I've tried all solutions I have found so far but the problem won't be solved until I rename the file. It could be an editor-related issue, but I think it's not a big deal to generate types in a different named file :) |
|
What is in your |
| $types = config('ziggy.output.types', Types::class); | ||
|
|
||
| $filesystem->put(base_path("{$name}.d.ts"), new $types($ziggy)); | ||
| $filesystem->put(base_path("{$name}-types.d.ts"), new $types($ziggy)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $filesystem->put(base_path("{$name}-types.d.ts"), new $types($ziggy)); | |
| $filesystem->put(base_path("{$name}-module.d.ts"), new $types($ziggy)); |
| file_put_contents( | ||
| base_path('resources/js/ziggy.d.ts'), | ||
| preg_replace('/\r?\n/', "\r\n", file_get_contents(base_path('resources/js/ziggy.d.ts'))), | ||
| base_path('resources/js/ziggy-types.d.ts'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| base_path('resources/js/ziggy-types.d.ts'), | |
| base_path('resources/js/ziggy-module.d.ts'), |
| base_path('resources/js/ziggy.d.ts'), | ||
| preg_replace('/\r?\n/', "\r\n", file_get_contents(base_path('resources/js/ziggy.d.ts'))), | ||
| base_path('resources/js/ziggy-types.d.ts'), | ||
| preg_replace('/\r?\n/', "\r\n", file_get_contents(base_path('resources/js/ziggy-types.d.ts'))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| preg_replace('/\r?\n/', "\r\n", file_get_contents(base_path('resources/js/ziggy-types.d.ts'))), | |
| preg_replace('/\r?\n/', "\r\n", file_get_contents(base_path('resources/js/ziggy-module.d.ts'))), |
| } | ||
|
|
||
| expect(base_path('resources/js/ziggy.d.ts'))->toEqualFile('./tests/fixtures/ziggy.d.ts'); | ||
| expect(base_path('resources/js/ziggy-types.d.ts'))->toEqualFile('./tests/fixtures/ziggy.d.ts'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expect(base_path('resources/js/ziggy-types.d.ts'))->toEqualFile('./tests/fixtures/ziggy.d.ts'); | |
| expect(base_path('resources/js/ziggy-module.d.ts'))->toEqualFile('./tests/fixtures/ziggy.d.ts'); |
| artisan('ziggy:generate --types-only'); | ||
|
|
||
| expect(base_path('resources/js/ziggy.d.ts'))->toBeFile(); | ||
| expect(base_path('resources/js/ziggy-types.d.ts'))->toBeFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expect(base_path('resources/js/ziggy-types.d.ts'))->toBeFile(); | |
| expect(base_path('resources/js/ziggy-module.d.ts'))->toBeFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think -module is a better prefix, because the file contains the module declaration for ziggy-js.
|
|
||
| expect(base_path('resources/js/custom.d.ts'))->toBeFile(); | ||
| expect(base_path('resources/js/ziggy.d.ts'))->not->toBeFile(); | ||
| expect(base_path('resources/js/custom-types.d.ts'))->toBeFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expect(base_path('resources/js/custom-types.d.ts'))->toBeFile(); | |
| expect(base_path('resources/js/custom-module.d.ts'))->toBeFile(); |
| expect(base_path('resources/js/custom.d.ts'))->toBeFile(); | ||
| expect(base_path('resources/js/ziggy.d.ts'))->not->toBeFile(); | ||
| expect(base_path('resources/js/custom-types.d.ts'))->toBeFile(); | ||
| expect(base_path('resources/js/ziggy-types.d.ts'))->not->toBeFile(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| expect(base_path('resources/js/ziggy-types.d.ts'))->not->toBeFile(); | |
| expect(base_path('resources/js/ziggy-module.d.ts'))->not->toBeFile(); |
| ['resources/js/x.js --types', ['resources/js/x.js', 'resources/js/x-types.d.ts']], | ||
| ['resources/js/y.ts --types', ['resources/js/y.js', 'resources/js/y-types.d.ts']], | ||
| ['resources/js/z.d.ts --types', ['resources/js/z.js', 'resources/js/z-types.d.ts']], | ||
| ['resources/scripts/foo --types', ['resources/scripts/foo.js', 'resources/scripts/foo-types.d.ts']], | ||
| ['resources/js --types', ['resources/js/ziggy.js', 'resources/js/ziggy-types.d.ts']], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ['resources/js/x.js --types', ['resources/js/x.js', 'resources/js/x-types.d.ts']], | |
| ['resources/js/y.ts --types', ['resources/js/y.js', 'resources/js/y-types.d.ts']], | |
| ['resources/js/z.d.ts --types', ['resources/js/z.js', 'resources/js/z-types.d.ts']], | |
| ['resources/scripts/foo --types', ['resources/scripts/foo.js', 'resources/scripts/foo-types.d.ts']], | |
| ['resources/js --types', ['resources/js/ziggy.js', 'resources/js/ziggy-types.d.ts']], | |
| ['resources/js/x.js --types', ['resources/js/x.js', 'resources/js/x-module.d.ts']], | |
| ['resources/js/y.ts --types', ['resources/js/y.js', 'resources/js/y-module.d.ts']], | |
| ['resources/js/z.d.ts --types', ['resources/js/z.js', 'resources/js/z-module.d.ts']], | |
| ['resources/scripts/foo --types', ['resources/scripts/foo.js', 'resources/scripts/foo-module.d.ts']], | |
| ['resources/js --types', ['resources/js/ziggy.js', 'resources/js/ziggy-module.d.ts']], |


Rename generated types file by adding
-typesto resolve issue discussed here #702